<?php

/**
 * @file z_hidden.php
 * @brief Test for hidden input fields
 * @author DyrTechnologies
 * @version V 1.0
 * @date Wed Dec 19 2007
 *
 *  Part of the CEFIRO dynamic web framework project
 *
 *  Copyright (C) 2007  Dyr technologies http://dyrtech.com.ve
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

if (!defined('CEFIRO')) define("CEFIRO",substr(__FILE__,0,strpos(__FILE__,"cefiro"))."cefiro/widgets/cefiro.php");
require_once(CEFIRO);
require_once(CEF_MAILER);
require_once(CEF_TEXTBOX);
require_once(CEF_BUTTON3D);

function getMailer($args){

	$yourmail = new textbox("email","Introduce your mail","something@somedomain.com");
	$yourmail->display_textbox();
	
	$sendButton = new button3d("send","Send");
	$sendButton->set_onClic("args=new Object();args['email']=zajax.$('email').value;zajax.call('zajax/mailer/z_mailer.php','sendMail',args)");
	$sendButton->display_button3d();

	global $smarty;
	$smarty->template_dir = dirname(__FILE__).'/';

	addAssign('widgetTitle','innerHTML',"<p class='title_blue'>Mailer</p>");
	addAssign('widgetDisplay','innerHTML',$smarty->fetch('z_mailer.tpl'));

	$src  = "<p>";
	$src .= "\$yourmail = new textbox(\"email\",\"Introduce your mail\",\"something@somedomain.com\");<br>";
	$src .= "\$yourmail->display_textbox();<br>";
	
	$src .= "\$sendButton = new button3d(\"send\",\"Send\");<br>";
	$src .= "\$sendButton->set_onClic(\"args=new Object(); args['email']=zajax.$('email').value; zajax.call('zajax/mailer/z_mailer.php','sendMail',args)\");<br>";
	$src .= "\$sendButton->display_button3d();<br><br>";
	
	$src .= "function sendMail(\$args){<br>";
  	$src .= "\$to = \$args['email'];<br>";
  	$src .= "\$from = \"CEFIRO@dyrtech.com.ve\";<br>";
  	$src .= "mailer::mail(\$to,\$from,\"CEFIRO SAYS HI!\",\"This is an automated message welcoming you to the CEFIRO Framework.\");<br>";
	$src .= "}<br>";
	
	$src .= "</p>";


	addAssign('srcTitle','innerHTML',"<p class='title_red'>Source</p>");
	addAssign('srcDisplay','innerHTML',$src);

	addAssign('tplTitle','innerHTML',"<p class='title_green'>Smarty Template</p>");
	addAssign('tplDisplay','innerHTML',"<p>{\$email}{\$send}</p>");

	return processResponse();

}

function sendMail($args){
  	$to = $args['email'];
  	$from = "CEFIRO@dyrtech.com.ve";
  	mailer::mail($to,$from,"CEFIRO SAYS HI!","This is an automated message welcoming you to the CEFIRO Framework.");
}

?>